home *** CD-ROM | disk | FTP | other *** search
- #ifndef _DTCODEBK_HPP
- #define _DTCODEBK_HPP
-
- #if defined( _DEBUG ) && defined( new )
- # undef new
- # undef delete
- # define _REDEFINE_WNEW
- #endif
-
- #include <wcvector.h>
-
- #ifdef _REDEFINE_WNEW
- # include "wnew.hpp"
- #endif
-
- #include "mtdef.hpp"
-
- class MMEvent;
- class WStringList;
- class SaveSource;
- class SaveBlock;
- class DTObject;
- class UserFunction;
- class ostream;
-
- enum UFScope {
- UFPublic,
- UFPrivate,
- UFProtected,
- UFGeneratedPublic, // C++ Only
- UFPrivateProtected, // Java only
- UFDefault, // Java only
- UFEvent, // Events are in Event scope.
- };
-
- enum CMCodeBlock {
- CMCHppPrefix,
- CMCClassContents,
- CMCGeneratedClassContents,
- CMCHppSuffix,
-
- CMCCppPrefix,
- CMCCppSuffix,
-
- CMCNumBlocks,
- };
-
- enum CMFile {
- CMFileHPP,
- CMFileCPP,
- CMFileJava,
- CMFileNumFiles,
- };
-
- enum CCType {
- CCClassName,
- CCFunctionName,
- CCVariableUsage
- };
-
-
- class METACLASSDEF DTCodeBlockBase : public WObject
- {
- public:
- virtual WString GetName() const = 0;
- virtual const MMEvent * GetEventDef() const = 0;
- virtual int operator == ( const DTCodeBlockBase & ) const = 0;
- virtual int operator < ( const DTCodeBlockBase & ) const = 0;
-
- //
- // EventFuncName
- //
- // Form1::cb_1_Click
- //
- virtual void GetEventFuncName( WString &name ) const = 0;
-
- //
- // DTObj
- //
- // Events are associated with a DTObject -- the object that
- // triggers the event.
- //
- virtual DTObject * GetDTObj() const = 0;
-
- //
- // EventOwner is separate from the DTObj. I hope that it
- // is obsolete.
- //
- virtual void SetEventOwner( DTObject * owner ) = 0;
-
- //
- // Open the event in a code editor
- //
- virtual WBool EditEvent( WBool visible = TRUE ) = 0;
-
- //
- // SourceLine
- //
- // These are used to determine where in the generted code
- // file an event is. Necessary for debugging.
- //
- virtual void SetSourceLine( int line ) = 0;
- virtual int GetSourceLine( void ) const = 0;
-
- //
- // Save/Load
- //
- // An Event can request an additional block in the .wxf
- // file by returning TRUE from HasSaveInfo; then a block
- // is created and Save is called.
- //
- virtual WBool HasSaveInfo() = 0;
- virtual WBool Save( SaveSource & save ) = 0;
- virtual WBool Load( SaveBlock * load ) = 0;
-
- //
- // TheCode
- //
- // GetTheCode
- // If parameterized is TRUE, GetTheCode returns a parameterized
- // copy of the source code which must be destroyed. Otherwise,
- // a copy of the original code is returned -- don't destroy it!
- //
- // SetTheCode always clears the strings out of 'code'.
- //
- virtual WBool HasCode() const = 0;
- virtual void SetTheCode( WStringList & code, WBool parameterized ) = 0;
- virtual void GetTheCode( WStringList & code, WBool parameterized ) const = 0;
-
- // ChangeCode
- //
- // Update the code contained in this event.
- //
- virtual WBool ChangeCode( CCType type, const WString &oldName,
- const WString &newName ) = 0;
-
- //
- // New style code generation:
- // Prototype -- "WBool cb_1_Click( WObject *, WEventData * );"
- // EventHandler -- { WClickEvent, WEventHandlerCast(...) },
- // Members -- the code lines
- //
- virtual void GeneratePrototype( ostream &, const WString & obj ) = 0;
- virtual void GenerateEventHandler( ostream &, const WString & obj ) = 0;
- virtual void GenerateMembers( ostream & ) = 0;
-
- //
- // Order is used to control the ordering of
- // events in the generated code.
- //
- virtual WInt GetOrder() const = 0;
- virtual void SetOrder( WInt ) = 0;
-
- //
- // Scope
- // - public/protected/private/generated public/private protected
- //
- virtual UFScope GetScope() const = 0;
- virtual void SetScope( UFScope ) = 0;
-
- //
- // GenCode
- //
- // True if this is a generated code block. It will only be shown
- // if the user has ShowReadOnly. If shown, it will be read only.
- //
- virtual WBool GetGenCode() const = 0;
- virtual void SetGenCode( WBool ) = 0;
-
- //
- // IsPrototype
- //
- // True if this code block is a function prototype
- //
- virtual WBool GetIsPrototype() const = 0;
- virtual void SetIsPrototype( WBool proto = TRUE ) = 0;
-
- //
- // AssociatedPrototype and AssociatedDefinition
- //
- // Get the associated prototype if this is a definition block,
- // or get the associated definition if this is a prototype block.
- //
- virtual DTCodeBlockBase * GetAssociatedPrototype() const = 0;
- virtual DTCodeBlockBase * GetAssociatedDefinition() const = 0;
- virtual void SetAssociatedPrototype( DTCodeBlockBase * ) = 0;
- virtual void SetAssociatedDefinition( DTCodeBlockBase * ) = 0;
-
- //
- // UserFunction
- //
- virtual UserFunction * GetUserFunction() = 0;
-
- //
- // SpecialBlockID
- //
- // If this is a special block (HPP Prefix, etc.), then
- // return its id. Otherwise, return CMCNumBlocks
- //
- virtual CMCodeBlock GetSpecialBlockID() const = 0;
- virtual void SetSpecialBlockID( CMCodeBlock ) = 0;
-
- //
- // GenerationFile
- //
- // The GenerationFile is the file that the code is emitted
- // into. Can be CMFileHPP, CMFileCPP, CMFileJava
- //
- virtual CMFile GetGenerationFile() const = 0;
- virtual void SetGenerationFile( CMFile ) = 0;
- };
-
- class DTUserFunctionVect : public WSortableVector< DTCodeBlockBase > {};
-
- //typedef WCPtrSortedVector< DTCodeBlockBase > DTCodeBlockList;
- class DTCodeBlockList : public WCPtrSortedVector< DTCodeBlockBase > {};
-
- class DTCodeBlockListList : public WCPtrOrderedVector< DTCodeBlockList > {};
-
- #endif // _DTCODEBK_HPP
-